<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {

	//系统首页
    public function index(){

        define('UID',is_login());
        if(UID){
            $category = D('Category')->getTree();
            //$lists    = D('Document')->lists(null);

            $this->assign('category',$category);//栏目
            //$this->assign('lists',$lists);//列表
            //$this->assign('page',D('Document')->page);//分页

            //print_r($category);

            $this->display();
        } else {
            $this->redirect('User/login');
        }
    }
    
    public function wodedingdan() {
        $this->login();
        if(IS_POST) {
            $status = $_POST['order_plan'];
            $desc = $_POST['error_op'];
            //do some data base operation
            $dbop = 1;
            if ($dbop) {
                //$this->success('operate success');
                $this->ajaxReturn(array('status' => 1, 'msg' => 'oprate success'));
                var_dump('dddd');die;
            } else {
                //$this->error('operate failed');
            }
        }
        $this->menu();
        $this->display();
    }
    
    public function pushOrder()
    {
        $data = array();
        $data['status']  = 0;
        $data['content'] = 'content';
        $this->ajaxReturn($data);

    }

    public  function getJson() {

        //$j = D('Category')->get_json();
        //echo $j;

        $Model = M();
        //进行原生的SQL查询
        $jsondata = $Model->query('SELECT * FROM `ot`.`offline_saomaInfo` WHERE `status` = 1');
        //echo "##".$jsondata."##";

        $jsondata = "{\"page\":\"1\",\"total\":19,\"records\":\"5\",\"rows\":[{\"id\":\"23\",\"cell\": [\"23\",\"2015-03-10 09:15:02\",\"123\",\"18916758895\",\"789\",null]},{\"id\":\"22\",\"cell\": [\"22\",\"2015-03-07 22:59:28\",\"123\",\"18916758895\",\"789\",null]},{\"id\":\"21\",\"cell\": [\"21\",\"2015-03-07 22:54:07\",\"123\",\"456\",\"789\",null]},{\"id\":\"20\",\"cell\": [\"20\",\"2015-03-07 22:53:08\",\"\",\"\",\"\",null]},{\"id\":\"19\",\"cell\": [\"19\",\"2015-03-07 19:50:14\",\"123\",\"456\",\"789\",null]},{\"id\":\"18\",\"cell\": [\"18\",\"2015-03-07 19:49:30\",\"123\",\"456\",\"789\",null]},{\"id\":\"17\",\"cell\": [\"17\",\"2015-03-07 17:32:40\",\"bbbird123\",\"13003108669\",\"12\",null]},{\"id\":\"16\",\"cell\": [\"16\",\"2015-03-07 17:32:20\",\"123\",\"456\",\"789\",null]},{\"id\":\"15\",\"cell\": [\"15\",\"2015-03-07 17:31:18\",\"123\",\"456\",\"789\",null]},{\"id\":\"14\",\"cell\": [\"14\",\"2015-03-07 17:29:40\",\"123\",\"456\",\"789\",null]},{\"id\":\"13\",\"cell\": [\"13\",\"2015-03-07 17:29:08\",\"123\",\"456\",\"789\",null]},{\"id\":\"12\",\"cell\": [\"12\",\"2015-03-07 17:29:02\",\"bbbird123\",\"13003108669\",\"18\",null]},{\"id\":\"11\",\"cell\": [\"11\",\"2015-03-07 17:28:45\",\"bbbird123\",\"13003108669\",\"18\",null]},{\"id\":\"10\",\"cell\": [\"10\",\"2015-03-07 17:26:52\",\"123\",\"456\",\"789\",null]},{\"id\":\"9\",\"cell\": [\"9\",\"2015-03-07 17:25:33\",\"123\",\"456\",\"789\",null]},{\"id\":\"8\",\"cell\": [\"8\",\"2015-03-07 17:24:20\",\"123\",\"456\",\"789\",null]},{\"id\":\"7\",\"cell\": [\"7\",\"2015-03-07 17:23:37\",\"123\",\"456\",\"789\",null]},{\"id\":\"6\",\"cell\": [\"6\",\"2015-03-07 17:23:20\",\"123\",\"456\",\"789\",null]},{\"id\":\"5\",\"cell\": [\"5\",\"2015-03-07 17:21:28\",\"123\",\"456\",\"789\",null]}]}";

        echo "$jsondata";

    }

}